package com.kebabeaters.nakebab.client.presenter.widget;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.Window;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.PresenterWidget;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import com.gwtplatform.mvp.client.proxy.PlaceRequest;
import com.kebabeaters.nakebab.client.event.NavigationAutoModeRequest;
import com.kebabeaters.nakebab.client.place.NameTokens;

public class CircleLayoutPresenterWidget extends
		PresenterWidget<CircleLayoutPresenterWidget.Display> {

	private final PlaceManager placeManager;

	public interface Display extends View {
		HasClickHandlers menuRankUserOnClick();

		HasClickHandlers menuRankTasterOnClick();

		HasClickHandlers menuUserProfilOnClick();

		HasClickHandlers menuUserTastersOnClick();

		HasClickHandlers menuAboutOnClick();

		HasClickHandlers menuRestaurantAddOnClick();

		HasClickHandlers menuRestaurantSearchOnClick();

		HasClickHandlers menuRestaurantMapOnClick();
		
		void setAutoModeEnabled(boolean enabled);
	}

	@Inject
	public CircleLayoutPresenterWidget(EventBus eventBus, Display view,
			PlaceManager placeManager) {
		super(eventBus, view);
		this.placeManager = placeManager;
	}

	@Override
	protected void onBind() {
		super.onBind();

		registerHandler(getView().menuAboutOnClick().addClickHandler(
				new ClickHandler() {

					@Override
					public void onClick(ClickEvent event) {
						/*placeManager.revealPlace(new PlaceRequest(
								NameTokens.about));*/
						Window.alert("Przepraszamy! Strona w budowie.");
					}
				}));

		registerHandler(getView().menuRankTasterOnClick().addClickHandler(
				new ClickHandler() {

					@Override
					public void onClick(ClickEvent event) {
						placeManager.revealPlace(new PlaceRequest(
								NameTokens.tasterKebabRanking));
					}
				}));

		registerHandler(getView().menuRankUserOnClick().addClickHandler(
				new ClickHandler() {

					@Override
					public void onClick(ClickEvent event) {
						placeManager.revealPlace(new PlaceRequest(
								NameTokens.kebabRanking));
					}
				}));

		registerHandler(getView().menuRestaurantAddOnClick().addClickHandler(
				new ClickHandler() {

					@Override
					public void onClick(ClickEvent event) {
						/*placeManager.revealPlace(new PlaceRequest(
								NameTokens.restaurantAdd));*/
						Window.alert("Przepraszamy! Strona w budowie.");
					}
				}));

		registerHandler(getView().menuRestaurantMapOnClick().addClickHandler(
				new ClickHandler() {

					@Override
					public void onClick(ClickEvent event) {
						/*placeManager.revealPlace(new PlaceRequest(
								NameTokens.restaurantMap));*/
						Window.alert("Przepraszamy! Strona w budowie.");
					}
				}));

		registerHandler(getView().menuRestaurantSearchOnClick()
				.addClickHandler(new ClickHandler() {

					@Override
					public void onClick(ClickEvent event) {
						/*placeManager.revealPlace(new PlaceRequest(
								NameTokens.restaurantSearch));*/
						Window.alert("Przepraszamy! Strona w budowie.");
					}
				}));

		registerHandler(getView().menuUserProfilOnClick().addClickHandler(
				new ClickHandler() {

					@Override
					public void onClick(ClickEvent event) {
						/*placeManager.revealPlace(new PlaceRequest(
								NameTokens.profile));*/
						Window.alert("Przepraszamy! Strona w budowie.");
					}
				}));

		registerHandler(getView().menuUserTastersOnClick().addClickHandler(
				new ClickHandler() {

					@Override
					public void onClick(ClickEvent event) {
						/*placeManager.revealPlace(new PlaceRequest(
								NameTokens.tastersRanking));*/
						Window.alert("Przepraszamy! Strona w budowie.");
					}
				}));

		getEventBus().addHandler(NavigationAutoModeRequest.getType(),
				new NavigationAutoModeRequest.Handler() {

					@Override
					public void onRequest(NavigationAutoModeRequest event) {
						getView().setAutoModeEnabled(true);
					}
				});
	}
}
